package com.snow.useviewdemo.function2.hindicon

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.snow.useviewdemo.SplashActivity
import com.snow.useviewdemo.base.BaseKtActivity
import com.snow.useviewdemo.databinding.ActivityHindDeskAppIconBinding
import com.snow.useviewdemo.util.LogUtils

/**
 * Created by zhaoyingtao
 * Date: 2021/11/8
 * Describe:
 */
class HindDeskAppIconActivity : BaseKtActivity<ActivityHindDeskAppIconBinding>() {
    override fun setViewData(savedInstanceState: Bundle?) {
        binding.button01.setOnClickListener {
            HindAppIconUtils.dismissAppIcon(HindDeskAppIconActivity@ this, SplashActivity::class.java.name, OpenHighActivity::class.java.name)
        }
        binding.button02.setOnClickListener {
            HindAppIconUtils.showAppIcon(HindDeskAppIconActivity@ this, SplashActivity::class.java.name)
        }
        var dataList = mutableListOf<String>()
        var testItemAdapter = TestItemAdapter(dataList, this)
        binding.contentRlv.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
        binding.contentRlv.adapter = testItemAdapter
        for (index in 1..20) {
            dataList.add("position===$index")
        }
        testItemAdapter.notifyDataSetChanged()
        forMethod()
    }

    private fun forMethod() {
        for (index in 1 until 10) {//输出结果 1 2 ... 9
            LogUtils.e("===index in 1 until 10==$index")
        }
        for (index in 1..10) {//输出结果 1 2 ... 10
            LogUtils.e("===index in 1..10==$index")
        }
        for (index in 10 downTo 1) {//输出结果 10 9 ... 1
            LogUtils.e("===index in 10 downTo 1==$index")
        }
        for (index in 1..10 step 2) {//输出结果 1 3 5 7 9
            LogUtils.e("===index in 1..10 step 2==$index")
        }
        val arrayListt = arrayListOf<String>()
        val arrayList = arrayListOf("a", "b", "c")
        for (index in arrayList.indices) {//输出结果 0 1 2
            LogUtils.e("===index in arrayList.indices==$index")
        }
        for (element in arrayList) {//输出结果 a b c
            LogUtils.e("===element in arrayList==$element")
        }
        for ((index, element) in arrayList.withIndex()) {//输出结果 0,a 1,b 2,c
            LogUtils.e("===(element,index) in arrayList.withIndex()===index==$index===element==$element")
        }
    }

    override fun getViewBinding() = ActivityHindDeskAppIconBinding.inflate(layoutInflater)


}